-- die_transform
-- create by dengc
-- 死亡转换为另一个元素

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 死亡时触发
    trigger = function(who, prop, arg)
        local monster = who;
        if not monster then
            return false;
        end

        if monster.type ~= OBJECT_TYPE_MONSTER then
            return false;
        end

        local toElement = prop[3];
        local toClass = DungeonM.queryElement(toElement, "class");
        local para = { ["class"] = toClass, ["element"] = toElement };
        DungeonM.transformGrid(toClass, monster:getPos(), GRID_STATE_OPEN, para);
    
        -- 如果是守护者飞艇，抛出事件
        if monster:getClassId() == 514 then
            EventMgr.fire(event.DEFENDER_SHIP_DIE, {["monster"] = monster,})
        end

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end 
};
